#ifndef GRAPHICSIPLIMGOBJECT_H
#define GRAPHICSIPLIMGOBJECT_H

#include <QGraphicsObject>
#include "nodeconfig.h"
#include "pfcmu_config.h"
#include "iplqimage.h"

const int EDGEWIDTH = 10;
const int EDGEHEIGHT = 10;

class GraphicsIplImgObject : public QGraphicsObject
{
    Q_OBJECT
public:
    explicit GraphicsIplImgObject(int width=PFCMU::WIDTH, int height=PFCMU::HEIGHT, QGraphicsObject *parent = 0);

    QRectF boundingRect() const;
    QPainterPath shape() const;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);

    void setTitle(int vPos, int hPos, std::string title);
    void setTopTitle(int hPos, std::string title);
    void setBottomTitle(int hPos, std::string title);

    int getWidth() const;
    int getHeight() const;
    int getImageWidth() const;
    int getImageHeight() const;
    PFCMU::timestamp_t getCurrentTimeStamp() const;

    int getCurrentCam() const;
    void setCurrentCam(int num);

    void setThumb();

    IplImage *getRGBIplImage() const;
    IplImage *getOrigIplImage() const;

    void forceUpdate() const;

signals:
    void objectDoubleClicked(int cam);

protected:
    void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);

public slots:
    void onReceivedImg();

private:
    IplImage *m_OrigImageData;
    IplQImage *m_ImageData;
    int m_Width;
    int m_Height;
    int m_ImageWidth;
    int m_ImageHeight;
    PFCMU::timestamp_t m_CurrentTimeStamp;
    bool m_IsThumb;

    int m_CurrentCam;
    QStringList m_TopTitle;
    QStringList m_BottomTitle;

};

#endif // GRAPHICSIPLIMGOBJECT_H
